home *** CD-ROM | disk | FTP | other *** search
- // PatternMatcher.cp
-
- #ifndef PatternMatcher_h
- #include "PatternMatcher.h"
- #endif
- #ifndef Overflow_h
- #include "Overflow.h"
- #endif
-
- void PatternMatcher::SetTarget( ConstData theTarget )
- {
- Assert( theTarget.Length() > 0 );
-
- target = theTarget;
-
- uint8 largestAdvance = ( theTarget.Length() < maxuint8 )
- ? Asuint8( theTarget.Length() )
- : maxuint8;
-
- for ( uint32 c = 0; c <= maxuint8; c++ )
- advance[c] = largestAdvance;
-
- for ( uint8 distance = largestAdvance - 1; distance > 0; distance-- )
- advance[ *( theTarget.End() - 1 - distance ) ] = distance;
- }
-